package com.toppitch.site.data;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.toppitch.site.db.IGetFromResultSet;

public class Student extends User implements IGetFromResultSet {
	private String firstName;
	private String lastName;
	private String password;
	private String college;
	private String graduateSchool;
	private String yearOfGraduation;
	private String roleOfInterest;
	private String locationPreference;
	private String currentEmployer;
	private String jobTitle;
	private String formerEmployer;
	private String employerIndustry;
	private String availability;
	private String investingBackground;
	private String cvId;
	private String cvFileName;
	private int pitchCount;
	private int modelCount;
	// not stored in db
	private List<CareerInterest> careerInterests = new ArrayList<CareerInterest>();

	public void getFromResultSet(ResultSet rs) throws SQLException {
		firstName = rs.getString("firstName");
		lastName = rs.getString("lastName");
		email = rs.getString("email");
		password = rs.getString("password");
		college = rs.getString("college");
		graduateSchool = rs.getString("graduateSchool");
		yearOfGraduation = rs.getString("yearOfGraduation");
		roleOfInterest = rs.getString("roleOfInterest");
		locationPreference = rs.getString("locationPreference");
		currentEmployer = rs.getString("currentEmployer");
		jobTitle = rs.getString("jobTitle");
		formerEmployer = rs.getString("formerEmployer");
		employerIndustry = rs.getString("employerIndustry");
		availability = rs.getString("availability");
		investingBackground = rs.getString("investingBackground");
		cvId = rs.getString("cvId");
		cvFileName = rs.getString("cvFileName");
		photoId = rs.getString("photoId");
		pitchCount = rs.getInt("pitchCount");
		modelCount = rs.getInt("modelCount");
	}

	public String toInsertString() {
		return toInsertString("student", firstName, //
				lastName, //
				email.toLowerCase(), //
				password, //
				college, //
				graduateSchool, //
				yearOfGraduation, //
				roleOfInterest, //
				locationPreference, //
				currentEmployer, //
				jobTitle, //
				formerEmployer, //
				employerIndustry, //
				availability, //
				investingBackground, //
				cvId, //
				cvFileName, //
				photoId, //
				pitchCount,//
				modelCount);//
	}

	public String toUpdateString() {
		return "update student set " + //
				"firstName='"
				+ firstName.replace("'", "''")
				+ "', "
				+ //
				"lastName='"
				+ lastName.replace("'", "''")
				+ "', "
				+ //
				"password='"
				+ password.replace("'", "''")
				+ "', "
				+ //
				"college='"
				+ college.replace("'", "''")
				+ "', "
				+ //
				"graduateSchool='"
				+ graduateSchool.replace("'", "''")
				+ "', "
				+ //
				"yearOfGraduation='"
				+ yearOfGraduation.replace("'", "''")
				+ "', "
				+ //
				"roleOfInterest='"
				+ roleOfInterest.replace("'", "''")
				+ "', "
				+ //
				"locationPreference='"
				+ locationPreference.replace("'", "''")
				+ "', "
				+ //
				"currentEmployer='"
				+ currentEmployer.replace("'", "''")
				+ "', "
				+ //
				"jobTitle='" + jobTitle.replace("'", "''")
				+ "', "
				+ //
				"formerEmployer='" + formerEmployer.replace("'", "''")
				+ "', "
				+ //
				"employerIndustry='" + employerIndustry.replace("'", "''")
				+ "', "
				+ //
				"availability='" + availability.replace("'", "''") + "', "
				+ //
				"investingBackground='"
				+ investingBackground.replace("'", "''") + "', " + //
				"cvId='" + cvId.replace("'", "''") + "', " + //
				"cvFileName='" + cvFileName.replace("'", "''") + "', " + //
				"photoId='" + photoId.replace("'", "''") + "', " + //
				"pitchCount=" + pitchCount + ", " + //
				"modelCount=" + modelCount + " " + //
				"where lower(email)='" + email.toLowerCase().replace("'", "''") + "'";
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getCollege() {
		return college;
	}

	public void setCollege(String college) {
		this.college = college;
	}

	public String getGraduateSchool() {
		return graduateSchool;
	}

	public void setGraduateSchool(String graduateSchool) {
		this.graduateSchool = graduateSchool;
	}

	public String getRoleOfInterest() {
		return roleOfInterest;
	}

	public void setRoleOfInterest(String roleOfInterest) {
		this.roleOfInterest = roleOfInterest;
	}

	public String getLocationPreference() {
		return locationPreference;
	}

	public void setLocationPreference(String locationPreference) {
		this.locationPreference = locationPreference;
	}

	public String getCurrentEmployer() {
		return currentEmployer;
	}

	public void setCurrentEmployer(String currentEmployer) {
		this.currentEmployer = currentEmployer;
	}

	public String getJobTitle() {
		return jobTitle;
	}

	public void setJobTitle(String jobTitle) {
		this.jobTitle = jobTitle;
	}

	public String getFormerEmployer() {
		return formerEmployer;
	}

	public void setFormerEmployer(String formerEmployer) {
		this.formerEmployer = formerEmployer;
	}

	public String getEmployerIndustry() {
		return employerIndustry;
	}

	public void setEmployerIndustry(String employerIndustry) {
		this.employerIndustry = employerIndustry;
	}

	public String getAvailability() {
		return availability;
	}

	public void setAvailability(String availability) {
		this.availability = availability;
	}

	public boolean isAvailableToPublic() {
		return !"Not be seen".equalsIgnoreCase(availability)
				&& !"Only for HFs".equalsIgnoreCase(availability);
	}

	public boolean isAvailableToHf() {
		return !"Not be seen".equalsIgnoreCase(availability);
	}

	public String getInvestingBackground() {
		return investingBackground;
	}

	public void setInvestingBackground(String investingBackground) {
		this.investingBackground = investingBackground;
	}

	public String getYearOfGraduation() {
		return yearOfGraduation;
	}

	public void setYearOfGraduation(String yearOfGraduation) {
		this.yearOfGraduation = yearOfGraduation;
	}

	public String getCvId() {
		return cvId;
	}

	public void setCvId(String cvId) {
		this.cvId = cvId;
	}

	public int getPitchCount() {
		return pitchCount;
	}

	public void setPitchCount(int pitchCount) {
		this.pitchCount = pitchCount;
	}

	public int getModelCount() {
		return modelCount;
	}

	public void setModelCount(int modelCount) {
		this.modelCount = modelCount;
	}

	public String getPitchCountString() {
		return pitchCount == 0 ? "None" : pitchCount + "";
	}

	public String getModelCountString() {
		return modelCount == 0 ? "None" : modelCount + "";
	}

	public String getFullName() {
		return firstName + " " + lastName;
	}

	public boolean isStudent() {
		return true;
	}

	public String getCvFileName() {
		return cvFileName;
	}

	public void setCvFileName(String cvFileName) {
		this.cvFileName = cvFileName;
	}

	public boolean isCvUploaded() {
		return null != cvId && null != cvFileName && !"".equals(cvId)
				&& !"".equals(cvFileName);
	}

	public List<CareerInterest> getCareerInterests() {
		return careerInterests;
	}
}
